
// BBSimpleDlg.h : header file
//

#pragma once

#include "WndMap.h"
#include "WndListTime.h"
#include "WndListEvent.h"
#include "WrapMap.h"
#include "WndTimeBar.h"
#include "../_inc_app/WndDisplay.h"
#include "../_inc_app/DxSoundEx.h"
#include "../_inc_app/IIntrReplayEx.h"

#include "FileOpenProgress.h"
#include "ListMgr.h"

#define WM_USER_UPDATE 0x100

// CBBSimpleDlg dialog
class CBBSimpleDlg : public CDialog
{
// Construction
public:
	CBBSimpleDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_BBSIMPLE_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

public:
	enum 
	{
		MAINSCREEN = 0,
		SUBSCREEN,
		MAX_SCREEN_COUNT
	};

public:

	CWnd				*m_pParentWnd;

private:
	CWndDisplay			*m_pWndScreen;
	CWndDisplay			*m_pWndSubScreen;
	CWndDisplay			*m_pWndDisplay[MAX_SCREEN_COUNT];
	CDxSoundEx			*m_pDxSoundEx;

	CWndListTime		m_WndListTime;
	CWndListEvent		m_WndListEvent;
	CWndTimeBar			m_WndTimeBar;
	CListMgr			*m_pListMgr;

	IIntrReplayEx		*m_pIntrPlayEx;

	CWndMap*			m_pWndMap;
	CWrapMap			m_WrapMap;

	CFileOpenProgress	m_DlgFileOpen;

	int					m_nTabIndex;

	BOOL				m_bPlayOn;
	SEARCH_TYPE			m_nSearchType;

	//////////////////////////////////////////////////////////////////////////
	//UI
	SIZE m_csScreen, m_csScrFull;
	SIZE m_csDisplay[MAX_SCREEN_COUNT];
	BOOL m_bMaximize;
	BOOL m_bFull;
	int m_nCurWinWidth, m_nCurWinHeight;
	int m_nFullScrChannel;
	BOOL m_bSwapScreen;
	DWORD m_dwRatioMode;

	BOOL m_bFileOpen;

	ST_IMAGE_INFO m_stImageInfo;

	ST_FILE_NAME_FORMAT m_stFileNameFormat;
	LPST_FILE_NAME_FORMAT m_lpstFileNameFormat;
	int m_nCurrentFileFormat;

	BOOL m_bLoadUserData;

	int m_nPlayerState;

	BYTE m_byReverse[MAX_CHANNEL];

	CDC* m_pDC;
public:

	void ShowLogo();
	void SetMapConnection(BOOL bState);

	void OpenRecFile();

	CListMgr *GetListMgr() { return m_pListMgr; };
	void GetAviFileNameFormat(LPST_AVI_NAME_FORMAT lpstAviNameFormat);
	void GetAviFileNameFormatList(int nIndex, LPST_FILE_NAME_FORMAT lpstFmt);
	void GetAviFileNameFormatDefault(LPST_FILE_NAME_FORMAT lpstFmt);

	void GetImageData(LPVOID pImageData);
	void GetUserData(LPVOID pUserData);
	void GetUserInfo(LPVOID pUserInfo);
	void TimeBarLoad(LPST_TIMEBAR_LOAD_DATA lpData);
	void PlayButtonControl(BOOL bEnable);

	//display
	void DisplayVideoStream(LPST_DISPLAY_VIDEO_STREAM lpStream);
	void DisplayUpdate(int nChannel);

	//audio
	void PlayAudioData(LPST_PLAY_AUDIO_DATA lpData);
	BOOL PlayAudioLoadStatus();
	void PlayAudioStop(); 

	//////////////////////////////////////////////////////////////////////////
	//CtlMessage 
	void PrintReport();

	//////////////////////////////////////////////////////////////////////////
	//PlbMessage
	void PlayForward();
	void PlayBackward();
	void Pause();
	void PlayStop();
	//void PlayStopReplay(LPST_NOTIFY_STOP lpstNotifyStop);
	void StepForward();
	void StepForwardKeyframe();
	void StepBackward();
	void StepBackwardKeyframe();


private:
	BOOL Initialize();
	void SetPositionWindows();

	BOOL CreateDisplay();

	BOOL CreateDxSound();
	void DeleteDxSound();

protected:
	static void CallbackReplay(UINT nCmd, DWORD wParam, void* lParam, void* pApp);
	static void CallbackMap(UINT nCmd, DWORD wParam, void *lParam, void *pApp);

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg long OnPlbMessage(UINT wParam, LONG lParam);
	afx_msg long OnUIUpdateDate(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
public:
	CString m_strGSensorX;
	CString m_strGSensorY;
	CString m_strGSensorZ;
	CString m_strSpeed;
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedBtnPlay();
	afx_msg void OnBnClickedBtnFileOpen();
	afx_msg void OnBnClickedBtnStop();
	afx_msg void OnBnClickedBtnPause();
	afx_msg void OnBnClickedBtnBackPlay();
	afx_msg void OnBnClickedBtnStepNext();
	afx_msg void OnBnClickedBtnStepPrev();
	afx_msg void OnBnClickedBtnPrint();
	afx_msg void OnBnClickedCheckFlipVert1();
	afx_msg void OnBnClickedCheckFlipHorz1();
	afx_msg void OnBnClickedCheckFlipVert2();
	afx_msg void OnBnClickedCheckFlipHorz2();
};
